/*
 * checkOut1.java
 *
 * Created on April 9, 2006, 6:47 AM
 */

package phs_project;
import java.awt.Component;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import java.util.*;
import java.util.Vector;
import java.text.*;
/**
 *
 * @author  TUNG
 */
public class checkOut1 extends javax.swing.JDialog {
    private Vector vector;
    public int OrderID;
    public Connection conn;
    public String roomName = "";
    public int vectorSize = 0; 
    /** Creates new form checkOut1 */
    public checkOut1(java.awt.Frame parent, boolean modal,Vector vt,int OrderID) {
        super(parent, modal);
        this.conn = new connectDatabase().getConnection();
        this.vector = vt;
        this.OrderID = OrderID;        
        this.vectorSize = new Search_Order(OrderID).size;
        //txtorderid
        initComponents();
        txtorderid.setText(""+OrderID);
        txtCusName.setText(new Search_Order(OrderID).getCusName());
        hiddenComponent();
        fillCostOFRoomTable();  
        fillServiceOfOrder();
        setSumPriceRoomInOrder();        
        setSumOrder();
        set_giam_gia();
        SumTotalOrder();
        khachtra();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel4 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        chbxhoanthanh = new javax.swing.JCheckBox();
        txtCompleteDate = new com.toedter.calendar.JDateChooser();
        jButton3 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        CostOfRoom = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        txtSumPriceRoom = new javax.swing.JFormattedTextField();
        txtKhachtra = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtSumTotal = new javax.swing.JFormattedTextField();
        txtGiamgia = new javax.swing.JFormattedTextField();
        txtthanhtien = new javax.swing.JFormattedTextField();
        jFormattedTextField1 = new javax.swing.JFormattedTextField();
        txtConlai = new javax.swing.JFormattedTextField();
        btnTraphong = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        txtorderid = new javax.swing.JTextField();
        txtCusName = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        CostOfServices = new javax.swing.JTable();
        jLabel9 = new javax.swing.JLabel();
        txtTongct = new javax.swing.JFormattedTextField();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblDichvuchung = new javax.swing.JTable();
        jLabel13 = new javax.swing.JLabel();
        txtSumOfServices = new javax.swing.JFormattedTextField();
        jPanel6 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jButton1.setText("Hoan tat");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Huy bo");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        chbxhoanthanh.setText("Hoan thanh don hang");
        chbxhoanthanh.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        chbxhoanthanh.setMargin(new java.awt.Insets(0, 0, 0, 0));

        jButton3.setText("Quay lai");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(chbxhoanthanh)
                .add(72, 72, 72)
                .add(txtCompleteDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(105, 105, 105)
                .add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(49, 49, 49)
                .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(41, 41, 41)
                .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(144, 144, 144))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton2)
                        .add(jButton1)
                        .add(jButton3))
                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(chbxhoanthanh, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(txtCompleteDate, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Cac phong thuoc don hang"));
        jScrollPane1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jScrollPane1.setAutoscrolls(true);
        CostOfRoom.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CostOfRoomMouseClicked(evt);
            }
        });

        jScrollPane1.setViewportView(CostOfRoom);

        jLabel1.setText("T\u1ed5ng ti\u1ec1n ph\u00f2ng  (1)");

        txtSumPriceRoom.setText("0");
        txtSumPriceRoom.setFont(new java.awt.Font("SansSerif", 1, 12));

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jLabel1)
                        .add(61, 61, 61)
                        .add(txtSumPriceRoom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 90, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(188, 188, 188))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 521, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 122, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 17, Short.MAX_VALUE)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(txtSumPriceRoom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        txtKhachtra.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Tong tien"));
        txtKhachtra.setMinimumSize(new java.awt.Dimension(22, 36));
        txtKhachtra.setPreferredSize(new java.awt.Dimension(22, 36));
        jLabel3.setText("Cong (1) + (2)");

        jLabel4.setText("Giam gia");

        jLabel5.setText("Thanh tien");

        jLabel6.setText("Khach tra");

        jLabel7.setText("Con lai");

        txtSumTotal.setText("0");
        txtSumTotal.setFont(new java.awt.Font("SansSerif", 1, 12));

        txtGiamgia.setText("0");

        txtthanhtien.setText("0");
        txtthanhtien.setFont(new java.awt.Font("SansSerif", 1, 12));

        jFormattedTextField1.setText("0");

        txtConlai.setText("0");

        btnTraphong.setText("Tra phong");
        btnTraphong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTraphongActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout txtKhachtraLayout = new org.jdesktop.layout.GroupLayout(txtKhachtra);
        txtKhachtra.setLayout(txtKhachtraLayout);
        txtKhachtraLayout.setHorizontalGroup(
            txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, txtKhachtraLayout.createSequentialGroup()
                .add(102, 102, 102)
                .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(txtKhachtraLayout.createSequentialGroup()
                        .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel5)
                            .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE))
                        .add(12, 12, 12))
                    .add(txtKhachtraLayout.createSequentialGroup()
                        .add(jLabel3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
                .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(btnTraphong)
                    .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(txtConlai)
                        .add(jFormattedTextField1)
                        .add(txtthanhtien)
                        .add(txtSumTotal, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
                        .add(txtGiamgia)))
                .add(193, 193, 193))
        );
        txtKhachtraLayout.setVerticalGroup(
            txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(txtKhachtraLayout.createSequentialGroup()
                .addContainerGap()
                .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(txtSumTotal, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel3))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(txtGiamgia, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(txtthanhtien, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel5))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jFormattedTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(txtKhachtraLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(txtConlai, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel7))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
                .add(btnTraphong))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "thong tin ve don hang"));
        jLabel10.setText("\u0110\u01a1n h\u00e0ng");

        jLabel12.setText("C\u1ee7a kh\u00e1ch");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel10)
                .add(100, 100, 100)
                .add(txtorderid, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 109, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(288, 288, 288)
                .add(jLabel12)
                .add(73, 73, 73)
                .add(txtCusName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 188, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(154, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel10)
                    .add(jLabel12)
                    .add(txtorderid, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(txtCusName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "D\u1ecbch v\u1ee5 chi ti\u1ebft c\u1ee7a t\u1eebng ph\u00f2ng"));
        jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
        jScrollPane2.setAutoscrolls(true);
        jScrollPane2.setInheritsPopupMenu(true);
        CostOfServices.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        CostOfServices.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CostOfServicesMouseClicked(evt);
            }
        });

        jScrollPane2.setViewportView(CostOfServices);

        jLabel9.setText("T\u1ed5ng   ");

        txtTongct.setText("0");
        txtTongct.setFont(new java.awt.Font("SansSerif", 1, 12));

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel9)
                        .add(21, 21, 21)
                        .add(txtTongct, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 105, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(txtTongct, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel9))
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "D\u1ecbch v\u1ee5 c\u1ee7a \u0111\u01a1n h\u00e0ng"));
        jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
        tblDichvuchung.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(tblDichvuchung);

        jLabel13.setText("Tong Ti\u1ec1n d\u1ecbch v\u1ee5  (2)");

        txtSumOfServices.setText("0");
        txtSumOfServices.setFont(new java.awt.Font("SansSerif", 1, 12));

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 521, Short.MAX_VALUE)
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(jLabel13)
                        .add(51, 51, 51)
                        .add(txtSumOfServices, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 111, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 21, Short.MAX_VALUE)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel13)
                    .add(txtSumOfServices, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder()));
        jButton4.setText("Quay lai");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("Hoan tat");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Huy bo");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .add(357, 357, 357)
                .add(jButton4)
                .add(55, 55, 55)
                .add(jButton5)
                .add(56, 56, 56)
                .add(jButton6)
                .addContainerGap(342, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton5)
                    .add(jButton4)
                    .add(jButton6))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .add(10, 10, 10)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(layout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(txtKhachtra, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE))
                            .add(layout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(16, 16, 16)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(txtKhachtra, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                    .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(21, 21, 21)
                .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(47, 47, 47))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
// TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
        this.dispose();
        new Search_Order(OrderID).setVisible(true);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
// TODO add your handling code here:
        // float tongtien = this.GetSumTotalOrder();
         //System.out.println(tongtien);
            CallableStatement cs;
            try{               
                cs = conn.prepareCall("{call hoantat(?)}");
                cs.setInt(1,OrderID);                
                cs.execute();                       
                        
            }
            catch(SQLException se){
                System.out.println("loi call hoan tat");
                System.out.println(se);
            }        
       jButton5.setEnabled(false);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void CostOfServicesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CostOfServicesMouseClicked
// TODO add your handling code here:
        int row = CostOfServices.getSelectedRow();
        //ten dich vu
        String nameServices = CostOfServices.getValueAt(row,0).toString();
        System.out.println(nameServices);
        //ten phong
        int rowR = CostOfRoom.getSelectedRow();
        String roomName = CostOfRoom.getValueAt(rowR,0).toString();
       // tinhtien1dv(nameServices,roomName);
    }//GEN-LAST:event_CostOfServicesMouseClicked

    private void CostOfRoomMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CostOfRoomMouseClicked
// TODO add your handling code here:
        int row = CostOfRoom.getSelectedRow();
        roomName = CostOfRoom.getValueAt(row,0).toString();
        System.out.println(roomName);
        fillCostOFServiceForRoom(roomName);
    }//GEN-LAST:event_CostOfRoomMouseClicked

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
        
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:                               
           
    }//GEN-LAST:event_jButton1ActionPerformed

    private void btnTraphongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTraphongActionPerformed
// TODO add your handling code here:         
        CallableStatement cs;
        float tongtien = this.GetSumTotalOrder();
        try{
            for(int i = 0;i<vector.size();i++){
                cs = conn.prepareCall("{call traphong(?,?,?)}");
                cs.setFloat(1,tongtien);
                cs.setString(2,vector.get(i).toString());
                cs.setInt(3,OrderID);
                cs.execute();
            }
        //conn.close();
        }   
        catch(SQLException se){
            System.out.println("loi call traphong");
            System.out.println(se);
        }
        JOptionPane.showMessageDialog(this,"tra phong thanh cong !!!");
        btnTraphong.setEnabled(false);
    }//GEN-LAST:event_btnTraphongActionPerformed
    
    /**
     * @param args the command line arguments
     */
    private void hiddenComponent(){
        if(vector.size() < vectorSize){
            this.setTitle("Tra mot phan don hang");
            //jPanel5.setVisible(false);
            //jLabel6.setVisible(false);
            //jFormattedTextField1.setVisible(false);
            jLabel7.setVisible(false);
            txtConlai.setVisible(false);
            jButton5.setVisible(false);
            this.pack();
            
        }
        if(vector.size() == vectorSize){
            this.setTitle("Tra tat ca cac phong trong don hang");
        }
    }
    
    private void fillCostOFRoomTable(){
        String sql = "";        
        sql = sql + "SELECT rooms.roomNumb AS [Tên Phòng], orderDetail.beginDate AS [Ngày Bắt Đầu], ";
        sql = sql + "orderDetail.endDate AS [Ngày Kết thúc], CONVERT(decimal, orderDetail.endDate - orderDetail.beginDate) AS [Tổng số ngày], ";
        sql = sql + "roomstype.price AS [Đơn giá], orderDetail.od_addition AS [Phí phát sinh], orderDetail.od_discount AS [Giảm giá], ";
        sql = sql +  "dbo.orderDetail.od_total AS [Thành tiền] ";
        sql = sql + " FROM roomstype INNER JOIN rooms ON roomstype.roomtypeId = rooms.type INNER JOIN orderDetail ON rooms.roomId = orderDetail.roomId ";
        sql = sql + "WHERE (orderDetail.orderId = " + OrderID + ") AND ((rooms.roomNumb = N'" + vector.get(0).toString() + "') ";
        for(int i = 1 ; i< (vector.size()-2);i++){
            sql = sql + "OR (rooms.roomNumb = N'" + vector.get(i).toString() + "') ";
        }
        sql = sql + "OR (rooms.roomNumb = N'" + vector.get(vector.size()-1).toString() + "')) ";
        addItemToTable(CostOfRoom,sql);
    }
    private void fillCostOFServiceForRoom(String Rname){
        String sqlSer = "";        
        sqlSer = sqlSer + "SELECT dbo.services.name AS [Tên dịch vụ], dbo.servicesDetail.sv_total AS [Thành tiền] FROM dbo.services INNER JOIN ";                
        sqlSer = sqlSer + "dbo.servicesDetail ON dbo.services.servicesId = dbo.servicesDetail.servicesId INNER JOIN dbo.orders ON dbo.servicesDetail.orderId = dbo.orders.orderId ";                
        sqlSer = sqlSer + "WHERE (dbo.ServicesDetail.orderId = " + OrderID + ") AND (dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + Rname + "')) ";
       /* for(int i = 1 ; i<vector.size();i++){
            sqlSer = sqlSer + "OR (rooms.roomNumb = N'" + vector.get(i).toString() + "') ";
        }*/
        addItemToTable(CostOfServices,sqlSer);
        float ttdv1ph = tongtiendv1room(OrderID,Rname);        
        txtTongct.setValue(new Float(ttdv1ph));
        txtTongct.setEditable(false);
        
    }
    private void fillServiceOfOrder(){
        if(vector.size() < vectorSize){
            String sql1 = "";            
            sql1 = sql1 + "SELECT dbo.services.name AS [Tên dịch vụ], dbo.services.prices AS [Phí dịch vụ], dbo.servicesDetail.sv_addition AS [Phụ phí], ";
            sql1 = sql1 + "dbo.servicesDetail.sv_discount AS [Giảm giá], dbo.servicesDetail.sv_total AS [Thành tiền] FROM dbo.services INNER JOIN ";              
            sql1 = sql1 + "dbo.servicesDetail ON dbo.services.servicesId = dbo.servicesDetail.servicesId INNER JOIN dbo.orders ON dbo.servicesDetail.orderId = dbo.orders.orderId ";
            sql1 = sql1 + "WHERE (dbo.ServicesDetail.orderId = " + OrderID + ") AND ((dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + vector.get(0).toString() + "')) ";
            for(int i = 1 ; i < vector.size()-2;i++){
                sql1 = sql1 + "OR (dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + vector.get(i).toString() + "')) ";
            }
            sql1 = sql1 + "OR (dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + vector.get(vector.size()-1).toString() + "'))) ";
            System.out.println(sql1);
            addItemToTable(tblDichvuchung,sql1);
            float sumServicesnRoom =  this.tongtiendvnhieuroom(OrderID,vector);
            txtSumOfServices.setValue(new Float(sumServicesnRoom));
            txtSumOfServices.setEditable(false);
        }
        if(vector.size() == vectorSize){
            String sql = "";                                                                      
            sql = sql + "SELECT dbo.services.name AS [Tên dịch vụ], dbo.services.prices AS [Phí dịch vụ], dbo.servicesDetail.sv_addition AS [Phụ phí], ";
            sql = sql + "dbo.servicesDetail.sv_discount AS [Giảm giá], dbo.servicesDetail.sv_total AS [Thành tiền] FROM dbo.services INNER JOIN ";              
            sql = sql + "dbo.servicesDetail ON dbo.services.servicesId = dbo.servicesDetail.servicesId INNER JOIN dbo.orders ON dbo.servicesDetail.orderId = dbo.orders.orderId ";
            sql = sql + "WHERE dbo.servicesDetail.orderId = " + OrderID  ;        
            addItemToTable(tblDichvuchung,sql);
            setSumPriceServicesInOrder();
        }        
    }
    private float tongtiendv1room(int OrderID,String rooname){
        String sql = "";
        float tiendv1room = 0;
        sql = sql + "SELECT sum(dbo.servicesDetail.sv_total) AS [Thành tiền] FROM dbo.services INNER JOIN dbo.servicesDetail ON ";               
        sql = sql +"dbo.services.servicesId = dbo.servicesDetail.servicesId INNER JOIN dbo.orders ON dbo.servicesDetail.orderId = dbo.orders.orderId ";
        sql = sql + "WHERE (dbo.ServicesDetail.orderId = " + OrderID + ") AND (dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + rooname + "')) ";
        try{
            Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()){
                tiendv1room = rs.getFloat(1);
                return tiendv1room;
            }
        st.close();
        conn.close();
        }
        catch(SQLException e){
        
        }
        return tiendv1room;
    }
    private float tongtiendvnhieuroom(int OrderID,Vector room_Name){
        String sql = "";
        float tiendvnroom = 0;
        sql = sql + "SELECT sum(dbo.servicesDetail.sv_total) AS [Thành tiền] FROM dbo.services INNER JOIN dbo.servicesDetail ON ";               
        sql = sql +"dbo.services.servicesId = dbo.servicesDetail.servicesId INNER JOIN dbo.orders ON dbo.servicesDetail.orderId = dbo.orders.orderId ";
        sql = sql + "WHERE (dbo.ServicesDetail.orderId = " + OrderID + ") AND ((dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + room_Name.get(0).toString() + "')) ";
         for(int i = 1 ; i < room_Name.size()-2;i++){
            sql = sql + "OR (dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + room_Name.get(i).toString() + "')) ";
        }
        sql = sql + "OR (dbo.servicesDetail.RoomNum = (SELECT roomid FROM dbo.rooms WHERE dbo.rooms.roomnumb = N'" + room_Name.get(room_Name.size()-1).toString() + "'))) ";
        try{
            Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()){
                tiendvnroom = rs.getFloat(1);
                return tiendvnroom;
            }
        st.close();
        conn.close();
        }
        catch(SQLException e){
        
        }
        return tiendvnroom;
     }
    private void setSumPriceRoomInOrder(){
        // tinh tong tien phong tra ra txtSumPriceRoom
        float sumRoom =  this.SumPriceRoomInOrder();
        txtSumPriceRoom.setValue(new Float(sumRoom));
        txtSumPriceRoom.setEditable(false);                
    }
    private float SumPriceRoomInOrder(){
        //tinh tong tien phong
        float sumPriceOr = 0;       
        String sql = "";
        sql = sql + "SELECT Sum([Thành tiền])  FROM tinhtienphong  ";
        sql = sql + "WHERE ([Mã đơn hàng] = " + OrderID + ") AND (([Tên phòng] = N'" + vector.get(0).toString() + "') ";
        for(int i = 1 ; i < vector.size()-2;i++){
            sql = sql + "OR ([Tên phòng] = N'" + vector.get(i).toString() + "') ";
        }
        sql = sql + "OR ([Tên phòng] = N'" + vector.get(vector.size()-1).toString() + "')) ";
        System.out.println(sql);
        try{
            Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            ResultSet rs = st.executeQuery(sql);
            while(rs.next()){
                sumPriceOr = rs.getFloat(1);
                return sumPriceOr;                
            }   
          conn.close();
        } catch(SQLException se){
            System.out.println("Loi Tong tien phong");
            System.out.println(se);
        }        
        return sumPriceOr;
    }
     private float SumPriceServicesInOrder(){
        // tinh tong tien dich vu         
        float sumPriceSer = 0;        
        String sql = "";
        sql = sql + "SELECT Sum([Thành tiền])  FROM tinhtiendichvu ";
        sql = sql + "WHERE ([Mã đơn hàng] = " + OrderID + ")" ;         
        System.out.println(sql);
        try{
            Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            ResultSet rs = st.executeQuery(sql);
            while(rs.next()){
                sumPriceSer = rs.getFloat(1);
                return sumPriceSer;
            }
           conn.close();
        }
        catch(SQLException se){
            System.out.println("tinh tong tien dv co loi ");
            System.out.println(se);
        }        
        return sumPriceSer;
    }
    private void setSumPriceServicesInOrder(){
         // tinh tong tien dich vu tra ra txtSumPriceServices     
        float sumServices =  this.SumPriceServicesInOrder();
        txtSumOfServices.setValue(new Float(sumServices));
        txtSumOfServices.setEditable(false);     
    }
    private void setSumOrder(){
        float sumOrder = 0;
        float sumRoom =  this.SumPriceRoomInOrder();
        float sumServices =  this.SumPriceServicesInOrder();
        float sumServicesnroom = this.tongtiendvnhieuroom(OrderID,vector);
        sumOrder = this.SumOrder(sumRoom,sumServices,sumServicesnroom);        
        txtSumTotal.setValue(new Float(sumOrder));
        txtSumTotal.setEditable(false);        
    }
    private float SumOrder(float sumRoom,float sumService,float sumServicesnroom){
        float sumTotalOrder = 0;
        if(vector.size() < vectorSize){
            sumTotalOrder = sumRoom + sumServicesnroom;
            return sumTotalOrder;
        }
        if(vector.size() == vectorSize){
            sumTotalOrder = sumRoom + sumService;
            return sumTotalOrder;
        }        
        return sumTotalOrder;
    }    
    private float giam_gia(){
        float discount = 0;
        String sql  = "SELECT discount FROM orders WHERE orderID = " + OrderID;        
        try{
            Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            ResultSet rs = st.executeQuery(sql);
            while(rs.next()){
                discount = rs.getFloat(1);
                return discount;
            }
            st.close();
           // conn.close();
        }
        catch(SQLException se){
            System.out.println("loi get giam gia");
            System.out.println(se);
        }
        return discount;
    }
    private void set_giam_gia(){
        float discount = 0;
        discount = this.giam_gia();
        txtGiamgia.setValue(new Float(discount));
        txtGiamgia.setEditable(false);
    }
    private void SumTotalOrder(){
        float sumTotalOr = 0;
        float sumRoom =  this.SumPriceRoomInOrder();
        float sumServices =  this.SumPriceServicesInOrder();
        float sumServicesnroom = this.tongtiendvnhieuroom(OrderID,vector);
        float sumOr = this.SumOrder(sumRoom,sumServices,sumServicesnroom);
        float dis = this.giam_gia();
        sumTotalOr = sumOr - (sumOr*dis/100);
        txtthanhtien.setValue(new Float(sumTotalOr));
        txtthanhtien.setEditable(false);
    }
    private float GetSumTotalOrder(){
        float sumTotalOr = 0;
        float sumRoom =  this.SumPriceRoomInOrder();
        float sumServices =  this.SumPriceServicesInOrder();
        float sumServicesnroom = this.tongtiendvnhieuroom(OrderID,vector);
        float sumOr = this.SumOrder(sumRoom,sumServices,sumServicesnroom);
        float dis = this.giam_gia();
        sumTotalOr = sumOr - (sumOr*dis/100);
        return sumTotalOr;
    }
    private void khachtra(){
        float khachtra = 0;
        String sql = "select totalfee from orders where OrderID = '" + OrderID + "'";
        try{
            Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            ResultSet rs = st.executeQuery(sql);
            while(rs.next()){
                khachtra = rs.getFloat(1);                
            }
            st.close();
           // conn.close();
        }
        catch(SQLException se){
            System.out.println("loi get giam gia");
            System.out.println(se);
        }
        jFormattedTextField1.setValue(new Float(khachtra));
        jFormattedTextField1.setEditable(false);
    }
    private void SQLRUN(String SQLTEXT) // Ham de chay cau truy van
    {
        try{            
            Statement stm = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
            stm.execute(SQLTEXT);            
            conn.close();
            stm.close();
            System.out.println(SQLTEXT);
        } catch(Exception e){
            e.printStackTrace();
        }       
    }           
    private void addItemToTable(JTable TableName,String sqltb )// Lay du lieu tu cau truy van dua vao tabe, nhieu ten bang
    {        
        //String sqltb=  "select * from Tenbang";
        new sqlDatabase().addDataTable(sqltb,TableName);
        
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new checkOut1(new javax.swing.JFrame(), true, new Vector(),0).setVisible(true);
            }
        });
    }      
    private SimpleDateFormat df2;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable CostOfRoom;
    private javax.swing.JTable CostOfServices;
    private javax.swing.JButton btnTraphong;
    private javax.swing.JCheckBox chbxhoanthanh;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable tblDichvuchung;
    private com.toedter.calendar.JDateChooser txtCompleteDate;
    private javax.swing.JFormattedTextField txtConlai;
    private javax.swing.JTextField txtCusName;
    private javax.swing.JFormattedTextField txtGiamgia;
    private javax.swing.JPanel txtKhachtra;
    private javax.swing.JFormattedTextField txtSumOfServices;
    private javax.swing.JFormattedTextField txtSumPriceRoom;
    private javax.swing.JFormattedTextField txtSumTotal;
    private javax.swing.JFormattedTextField txtTongct;
    private javax.swing.JTextField txtorderid;
    private javax.swing.JFormattedTextField txtthanhtien;
    // End of variables declaration//GEN-END:variables
    
}
